
pkgname=util-linux
pkgver=2.32
_pkgver=2.32
pkgrel=3
pkgdesc="Miscellaneous system utilities for Linux"
url="http://www.kernel.org/pub/linux/utils/util-linux/"
arch=('x86_64')
groups=('base')
depends=('pam' 'shadow' 'coreutils' 'glibc')
makedepends=('bc' 'systemd' 'python3')
conflicts=('util-linux-ng' 'eject' 'rfkill')
provides=("util-linux-ng=${pkgver}" 'eject' 'rfkill')
license=('GPL2')
options=('!libtool')
source=("https://www.kernel.org/pub/linux/utils/util-linux/v${_pkgver}/${pkgname}-${pkgver}.tar.xz"
        'uuidd.tmpfiles'
        'pam-login'
        'pam-common'
        'pam-su'
        'system-auth'
        'system-local-login'
        'system-login'
        'system-remote-login'
        'system-services')
backup=(etc/pam.d/chfn
        etc/pam.d/chsh
        etc/pam.d/login
        etc/pam.d/su
        etc/pam.d/su-l)
install=util-linux.install
sha256sums=('6c7397abc764e32e8159c2e96042874a190303e77adceb4ac5bd502a272a4734'
            '5de0aadbbeb1ebb0776f3c550111fe045dfdf3571c574f415c62ca1966c49616'
            '993a3096c2b113e6800f2abbd5d4233ebf1a97eef423990d3187d665d3490b92'
            'fc6807842f92e9d3f792d6b64a0d5aad87995a279153ab228b1b2a64d9f32f20'
            '51eac9c2a2f51ad3982bba35de9aac5510f1eeff432d2d63c6362e45d620afc0'
            '3eb67872e436817ec97c4f3795adba2cf1d3829ea4e107ef5747569e4eeb5746'
            '005736b9bd650ff5e5d82a7e288853776d5bb8c90185d5774c07231c1e1c64a9'
            '0924a1620e33d8321c3de5f9aa9efc328c0206465a643b0b10556be7cf0228b8'
            '005736b9bd650ff5e5d82a7e288853776d5bb8c90185d5774c07231c1e1c64a9'
            '6eb1acdd3fa9f71a7f93fbd529be57ea65bcafc6e3a98a06af4d88013fc6a567')

build() {
  cd ${pkgname}-${pkgver}

  ./configure --prefix=/usr \
              --libdir=/usr/lib \
              --localstatedir=/run \
              --enable-fs-paths-extra=/usr/bin:/usr/sbin \
              --enable-write \
              --enable-raw \
              --enable-vipw \
              --enable-newgrp \
              --enable-chfn-chsh \
              --enable-mesg \
              --enable-socket-activation \
              --with-python=3
              #--enable-libmount-force-mountinfo systemd 230 need?

  make
}

check() {
  # 1 fail libmount: tab files-py, leaving dep to test the rest
  make -C ${pkgname}-${pkgver} check
}

package() {
  cd ${pkgname}-${pkgver}

  make DESTDIR=${pkgdir} install

  cd ${pkgdir}
  
  chmod 4755 ${pkgdir}/usr/bin/{newgrp,ch{sh,fn}}

  install -Dm644 ${srcdir}/pam-common ${pkgdir}/etc/pam.d/chfn
  install -m644 ${srcdir}/pam-common ${pkgdir}/etc/pam.d/chsh
  install -m644 ${srcdir}/pam-login ${pkgdir}/etc/pam.d/login
  install -m644 ${srcdir}/pam-su ${pkgdir}/etc/pam.d/su
  install -m644 ${srcdir}/pam-su ${pkgdir}/etc/pam.d/su-l
  # Pam helper files
  install -m644 ${srcdir}/system-auth ${pkgdir}/etc/pam.d/system-auth
  install -m644 ${srcdir}/system-local-login ${pkgdir}/etc/pam.d/system-local-login
  install -m644 ${srcdir}/system-login ${pkgdir}/etc/pam.d/system-login
  install -m644 ${srcdir}/system-remote-login ${pkgdir}/etc/pam.d/system-remote-login
  install -m644 ${srcdir}/system-services ${pkgdir}/etc/pam.d/system-services

  install -Dm644 ${srcdir}/uuidd.tmpfiles ${pkgdir}/usr/lib/tmpfiles.d/uuidd.conf
  # fdisk fix for live-mode, until all moves to /usr
  ln -s /sbin/fdisk ${pkgdir}/usr/bin/fdisk
  # udisks2 fixes until all moves to /usr
  ln -s /bin/mount ${pkgdir}/usr/bin/mount
  ln -s /bin/umount ${pkgdir}/usr/bin/umount
}



